﻿<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>jquery写的选项卡-jq22.com</title>
<script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
<style>
* {
	margin:0;
	padding:0;
}
#div1 div {
	width:290px;
	height:200px;
	display:none;
	padding:5px;
	text-indent:2em;
	background:lavenderblush;
	color:#666;
	font-size:16px;
}
#div1 {
	font-size:0;
	width:300px;
	padding:20px;
	overflow:hidden;
}
#div1 input {
	font-size:14px;
	display:inline-block;
	width:100px;
	border:none;
	height:30px;
	line-height:30px;
	border-left:1px solid #cdcdcd;
	box-sizing:border-box;
}
#div1 input:first-of-type {
	border-left:none;
}
.active {
	background:darkcyan;
	color:#fff;
}
</style>
</head>
<body>
<div id="div1">
    <input type="button" value="111" class="active">
    <input type="button" value="222">
    <input type="button" value="333">
    <div style="display: block;">11111111111111</div>
    <div>22222222</div>
    <div>3333333333333333</div>
</div>

<script>
$(function() {
    $('#div1').find('input').click(function() {
        $('#div1').find('input').attr('class', '');
        $('#div1').find('div').css('display', 'none');
        $(this).attr('class', 'active');
        $('#div1').find('div').eq($(this).index()).css('display', 'block');
    })
})
</script>

</body>
</html>
